Layer-2 and layer-3 switches processed network traffic in software. Such processing, referred to herein as frame forwarding, includes but is not limited to classification of frames into bridged and routed classes, identification of frame protocol type, destination address lookup, identification of outgoing port(s), application of various filter conditions, application of input and output port states, Data Link layer translation/substitution, network layer modifications, etc. This invention introduces a new methodology, referred to herein as Code Vectors, which enable layer-2 and layer-3 switches to perform network traffic forwarding entirely in hardware, entirely in software, or in a combination in both hardware and software.